﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;

namespace browser4gp.core.Helpers
{

    /// <summary>
    /// Helper per l'environment
    /// </summary>
    public class EnvironmentHelper
    {


        /// <summary>
        /// Directory dell'applicazione (dove si trova l'exe)
        /// </summary>
        public static string ApplicationDirectory
        {
            get
            {
                return Directory.GetParent(Assembly.GetEntryAssembly().Location).ToString();
            }
        }


        /// <summary>
        /// Directory temporanea dell'applicazione
        /// </summary>
        public static string ApplicationTempDirectory
        {
            get
            {
                Process curProcess = Process.GetCurrentProcess();
                string tempDirectory = Path.Combine(ApplicationDirectory, "Temp", curProcess.Handle.ToString());
                if (!Directory.Exists(tempDirectory))
                {
                    Directory.CreateDirectory(tempDirectory);
                }
                return tempDirectory;
            }
        }

        /// <summary>
        /// Directory in cui trovare i plugin
        /// </summary>
        public static string PluginsDirectory
        {
            get
            {
                string pluginDirectory = Path.Combine(ApplicationDirectory, "Plugins");
                if (!Directory.Exists(pluginDirectory))
                {
                    Directory.CreateDirectory(pluginDirectory);
                }
                return pluginDirectory;
            }

        }
    }
}
